## STUDY 2 ANALYSIS AND DATA VISUALIZATIONS

metoo2_long <- read.csv("study2_replication_analysis.csv")

library(miceadds)
library(ggplot2)
library(sjPlot)
library(ggpubr)
library(patchwork)


## S9: Numerical results: Study 2 -- Table S9.1 and Table S9.2


### effect of communication (apology/denial) compared to allegation level resignation
metoo2_long$treatment <- as.factor(metoo2_long$treatment)
metoo2_long <- within(metoo2_long, treatment <- relevel(treatment, ref = "control"))

metoo2_long_affair <- metoo2_long %>% filter(scandal_sex == "affair")
metoo2_long_assault <- metoo2_long %>% filter(scandal_sex == "assault")


## affair

## S9.1
m1 <- lm(resign ~ treatment + resign_base, data = metoo2_long_affair)
summary(m1)
m1_robust <- lm.cluster(resign ~ treatment + resign_base, cluster="ResponseId", data = metoo2_long_affair)
summary(m1_robust)

## S9.2
m2 <- lm(likely ~ treatment + likely_base, data = metoo2_long_affair)
summary(m2)
m2_robust <- lm.cluster(likely ~ treatment + likely_base, cluster="ResponseId", data = metoo2_long_affair)
summary(m2_robust)

## assault

## S9.1
m3 <- lm(resign ~ treatment + resign_base, data = metoo2_long_assault)
summary(m3)
m3_robust <- lm.cluster(resign ~ treatment + resign_base, cluster="ResponseId", data = metoo2_long_assault)
summary(m3_robust)

## S9.2
m4 <- lm(likely ~ treatment + likely_base, data = metoo2_long_assault)
summary(m4)
m4_robust <- lm.cluster(likely ~ treatment + likely_base, cluster="ResponseId", data = metoo2_long_assault)
summary(m4_robust)



## MAIN TEXT FIGURE 2.

set_theme(base = theme_classic(), #To remove the background color and the grids  #To change the font typ
          axis.title.size = 1,  #To change axis title size
          axis.textsize.x = 1,  #To change x axis text size
          axis.textsize.y = 1)

fig2_resignation <- plot_models(m1, m3, show.values = TRUE,
                                title = "Resignation Support", rm.terms = c("resign_base"),
                                vline.color = "grey80",
                                axis.labels = c("", ""),
                                dot.size=4, line.size=1.3, value.size = 4, colors= "gs", show.legend = TRUE, axis.lim = c(-10,20),
                                robust=TRUE) + 
  theme(text = element_text(size=12))

fig2_resignation <- fig2_resignation + scale_color_discrete(labels = c("Affair", "Assault")) + 
  scale_colour_manual(labels = c("Assault", "Affair"),
                      values = c("grey50", "grey30")) +
  theme(legend.position = c(0.7, 0.1), legend.text = element_text(color = "black", size = 12),
        legend.direction="horizontal", legend.title=element_blank())

fig2_likely <- plot_models(m2, m4, show.values = TRUE,
                           title = "Belief in Allegation", rm.terms = c("likely_base"),
                           vline.color = "grey80",
                           axis.labels = c("Denial", "Apology"),
                           dot.size=4, line.size=1.3, value.size = 4, colors= "gs", show.legend = FALSE, axis.lim = c(-10,25),
                           robust=TRUE) + 
  theme(text = element_text(size=12)) + scale_color_discrete(labels = c("Affair", "Assault")) + 
  scale_colour_manual(labels = c("Assault", "Affair"),
                      values = c("grey50", "grey30")) 

fig2 <- fig2_likely | fig2_resignation
fig2

## ggsave("fig2.png", width = 8, height = 4, dpi = 600)  
